﻿using University.Workshop.Business;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Data;
using University.Workshop.Model;
using System.IO;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for PatientManagerTest and is intended
    ///to contain all PatientManagerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class PatientManagerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        private Patient LoadPatient()
        {
            Random randon = new Random(DateTime.Now.Millisecond);
            Patient patient = new Patient();
            patient.CIPatient = "44"+randon.Next(10000)+"8";
            patient.FirstName = "Alejandra";
            patient.LastName = "miss";
            patient.Address = "America";
            patient.CellPhone = 72434306;
            patient.Phone = 4444444;
            patient.Birthday = DateTime.Today;
            patient.Email = "alejandra@hotmail.com";
            patient.Gender = "Female";
            patient.StatePatient = true;
            patient.ImagePatient = null;
            return patient;
        }

        /// <summary>
        ///A test for InsertNewPatient
        ///</summary>
        [TestMethod()]
        public void InsertNewPatientTest()
        {
            Patient newPatient = LoadPatient(); // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = PatientManager.InsertNewPatient(newPatient);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for InsertNewPatientNULL 
        ///</summary>
        [TestMethod()]
        public void InsertNewPatientNullTest()
        {
            Patient newPatient = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = PatientManager.InsertNewPatient(newPatient);
            Assert.AreEqual(expected, actual);
            Assert.AreNotEqual(true, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
        /// <summary>
        ///A test for InsertNewPatientPicture 
        ///</summary>
        [TestMethod()]
        public void InsertNewPatientPictureTest()
        {
            Patient newPatient = LoadPatient(); // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            newPatient.ImagePatient = "anonimos.jpg";
            actual = PatientManager.InsertNewPatient(newPatient);
            Assert.AreEqual(expected, actual);
            Assert.AreNotEqual(false, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
        /// <summary>
        ///A test for ModifyPatient
        ///</summary>
        [TestMethod()]
        public void ModifyPatientTest()
        {
            string idPatient = "5733444"; // TODO: Initialize to an appropriate value
           // Patient patient = LoadPatient(); // TODO: Initialize to an appropriate value
            Patient patient = new Patient();
            patient.CIPatient = "5733444";
            patient.FirstName = "Cristina";
            patient.LastName = "Aguirre";
            patient.Address = "Cochabamba, av America";
            patient.CellPhone = 73883111;
            patient.Phone = 4444444;
            patient.Birthday = DateTime.Today;
            patient.Email = "cristina@hotmail.com";
            patient.Gender = "Female";
            patient.StatePatient = true;
            patient.ImagePatient = "cristina.jpg";
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = PatientManager.ModifyPatient(idPatient, patient);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for ModifyPatient Null
        ///</summary>
        [TestMethod()]
        public void ModifyPatientNullTest()
        {
            string idPatient = "6736789"; // TODO: Initialize to an appropriate value
            // Patient patient = LoadPatient(); // TODO: Initialize to an appropriate value
            Patient patient = new Patient();
            patient = null;
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = PatientManager.ModifyPatient(idPatient, patient);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for DisablePatient
        ///</summary>
        [TestMethod()]
        public void DisablePatientTest()
        {
            string idPatient = "5733444"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = PatientManager.DisablePatient(idPatient);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for DisablePatient NUll
        ///</summary>
        [TestMethod()]
        public void DisablePatientNullTest()
        {
            string idPatient = string.Empty; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = PatientManager.DisablePatient(idPatient);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for LoadDataPatient null
        ///</summary>
        [TestMethod()]
        public void LoadDataPatientNullTest()
        {
            string searchPatient = "1234567"; // TODO: Initialize to an appropriate value
            string expected = "Patient not Exist"; // TODO: Initialize to an appropriate value
            string actual;
            actual = PatientManager.LoadDataPatient(searchPatient);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for LoadDataPatient
        ///</summary>
        [TestMethod()]
        public void LoadDataPatientTest()
        {
            string searchPatient = "6736789"; // TODO: Initialize to an appropriate value
            string expected = "Aguirre,Pablo"; // TODO: Initialize to an appropriate value
            string actual;
            actual = PatientManager.LoadDataPatient(searchPatient);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for CiLoadDataGridViewSearchPatient
        ///</summary>
        [TestMethod()]
        public void LoadDataGridViewSearchCiPatientTest()
        {
            string searchPatient = "Manuel"; // TODO: Initialize to an appropriate value
            string CiPatient = "5733999"; // TODO: Initialize to an appropriate value
            DataTable actual;
            actual = PatientManager.LoadDataGridViewSearchPatient(searchPatient);
            Assert.AreEqual(CiPatient, actual.Rows[0]["CiPatient"].ToString());
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for FirstName LoadDataGridViewSearchPatient
        ///</summary>
        [TestMethod()]
        public void LoadDataGridViewSearchFisrtNamePatientTest()
        {
            string searchPatient = "5733999"; // TODO: Initialize to an appropriate value
            string firstName = "Manuel"; // TODO: Initialize to an appropriate value
            DataTable actual;
            actual = PatientManager.LoadDataGridViewSearchPatient(searchPatient);
            Assert.AreEqual(firstName, actual.Rows[0]["FirstName"].ToString());
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for LastNameLoadDataGridViewSearchPatient
        ///</summary>
        [TestMethod()]
        public void LoadDataGridViewSearchLastNamePatientTest()
        {
            string searchPatient = "Rivas"; // TODO: Initialize to an appropriate value
            string CiPatient = "5733999"; // TODO: Initialize to an appropriate value
            DataTable actual;
            actual = PatientManager.LoadDataGridViewSearchPatient(searchPatient);
            Assert.AreEqual(CiPatient, actual.Rows[0]["CiPatient"].ToString());
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for LoadDataGridViewPatient
        ///</summary>
        [TestMethod()]
        public void LoadDataGridViewPatientTest()
        {
            //DataTable expected = null; // TODO: Initialize to an appropriate value
            DataTable actual;
            actual = PatientManager.LoadDataGridViewPatient();
            Assert.IsTrue(actual.Rows.Count>=1);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
